package com.neusoft.resturant.controller;

import com.neusoft.resturant.entity.ResBanner;
import com.neusoft.resturant.entity.ResDishes;
import com.neusoft.resturant.service.IResBannerService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 轮播图Controller
 * 
 * @author 文豪
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/restaurant/banner")
public class ResBannerController
{
    @Autowired
    private IResBannerService resBannerService;

    /**
     * 查询轮播图列表
     */

    //    http://localhost:8081/restaurant/banner/1
    @GetMapping("/{id}")
    public ResBanner getInfo(@PathVariable(value = "id") Long bannerId) {
        System.out.println("id=" + bannerId);
        ResBanner banner = resBannerService.selectResBannerById(bannerId);
        return banner;
    }

    /**
     * 新增轮播图
     */

    @PostMapping("/add")
    public int add(@RequestBody ResBanner resBanner)
    {
        System.out.println("新增成功");
        return (resBannerService.insertResBanner(resBanner));
    }

    /**
     * 修改轮播图
     */

    @PutMapping("/edit")
    public int edit(@RequestBody ResBanner resBanner)
    {
        System.out.println("修改成功");
        return (resBannerService.updateResBanner(resBanner));
    }

    /**
     * 删除轮播图
     */

	@DeleteMapping("/remove/{id}")
    public int remove(@PathVariable Long[] id)
    {
        return (resBannerService.deleteResBannerByIds(id));
    }
}
